"""Controller for current students."""

from mnemoply.controllers.lookup import TableLookupDataSource
from mnemoply.controllers.Student import StudentController, StudentsInGroupItemTab, AgreementItemTab
from mnemoply.model.field import Student
from mnemoply.controllers.lookup import LookupController, TableCol
from mnemoply.controllers.crud import CRUDController

class StudentAndAgreementController(LookupController, CRUDController):
    """Controller for students."""
    model_object = Student
    lookup_columns = [
        TableCol(name='id', caption=_("ID"),size=4),
        TableCol(name='student', caption=_("Student")),
        TableCol(name='customer', caption=_("Customer")),
        TableCol(name='agreement', caption=_("Agreements")),
        TableCol(name='office', caption=_("Office")),
        TableCol(name='groups', caption=_("Groups")),
        TableCol(name='amount_of_customer', caption=_("Amount of customer"),size=5),
        TableCol(name='amount_of_agreement', caption=_("Amount of agreement")),
        ]
    def __init__(self):
        self.view_fields = StudentController.view_fields
        self.edit_fields = StudentController.edit_fields
        self.item_tabs = [StudentsInGroupItemTab(), AgreementItemTab()]

        LookupController.__init__(self,
            data_source=TableLookupDataSource('student_and_agreement'),
            columns=self.lookup_columns,
            mass_actions_class=Student,
        )
        CRUDController.__init__(self, model_object=self.model_object)
        self.title = _("Student and agreement")
        self.local_menu = []
exposed = StudentAndAgreementController()
